﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace SimpleMVVM.ViewModels
{
    public class MVVMTestViewModel : ViewModelBase
    {
        public MVVMTestViewModel()
        {
            Name = "MVVMLight简单测试";
            Title = "MainWindow";
            ShowCommand = new RelayCommand<string>(Show);
        }
        //RelayCommand<T>是带参，接收前台CommandParater传递的object
        public RelayCommand<string> ShowCommand { get; private set; }
        private string _name;
        public string Name
        {
            get { return _name; }
            set
            {
                _name = value;
                //后台VM改变了前台view绑定的属性后，会通知UI刷新
                RaisePropertyChanged();
            }
        }
        private string _title;
        public string Title
        {
            get { return _title; }
            set
            {
                _title = value;
                RaisePropertyChanged();
            }
        }
        public void Show(string content)
        {
            Name = "点击了按钮";
            Title = "我是标题";
            MessageBox.Show(content);
        }
    }
}
